/*
* AeroWindow - jQuery Plugin (v3.51)
* Copyright 2010, Christian Goldbach
* Dual licensed under the MIT or GPL Version 2 licenses.
* 
* Project Website:
* http://www.soyos.net/aerowindow-jquery.html
* http://www.soyos.net
*
*
*
* Requires Easing Plugin for Window Animations:
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
*
* Changelog:
* ~~~~~~~~~~
* Version 3.51 (2010-06-09) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Added more config options:
* New Feature: Window get the focus by clicking window buttons
* Bugfix: Resizing to regular Size
*
* Version 3.5 (2010-06-09) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Added more config options:
* - WindowAnimationSpeed 
*
* Bugfix: iFrames can now change the size correctly
* Bugfix: The buttons now look clean, in all configurations
* Bugfix: window without Maximize button can not be maximized by double-clicking on the header
* Bugfix: When clicking on the buttons appear no more # in the Browser URL 
* Bugfix: Dragging is not longer possible by the content area. Only by Header.
* Bugfix: The content can now be scrolled
* Bugfix: Fixed IE JavaScript crashes
*
* Version 2.0 (2010-06-01) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Added more config options:
* - WindowResizable: 
* - WindowMaximize    
* - WindowMinimize    
* - WindowClosable   
* - WindowDraggable  
*
* Date: 2010-06-01
*/

(function ($) {
    var methods = {
        init: function (options) {
            return this.each(function () {
                var settings = {
                    AutoOpen: false,
                    WindowTitle: null,
                    WindowPositionTop: 60,            /* Posible are pixels or 'center' */
                    WindowPositionLeft: 10,            /* Posible are pixels or 'center' */
                    WindowWidth: 0,           /* Only pixels */
                    WindowHeight: 0,           /* Only pixels */
                    WindowMinWidth: 250,           /* Only pixels */
                    WindowMinHeight: 250,             /* Only pixels */
                    WindowResizable: true,          /* true, false*/
                    WindowMaximize: true,          /* true, false*/
                    WindowMinimize: true,          /* true, false*/
                    WindowClosable: true,          /* true, false*/
                    WindowDraggable: true,          /* true, false*/
                    WindowStatus: 'regular',     /* 'regular', 'maximized', 'minimized', 'hidden' */
                    WindowPrevStatus: 'regular',     /* 'regular', 'maximized', 'minimized' */
                    WindowAnimationSpeed: 500,
                    WindowAnimation: 'easeOutElastic',
                    DeferLoad: true,
                    WindowParentSelector: '',
                    CloseAfterSubmit: true,
                    Opacity:1,
                    AutoSize: false
                };
                var $this = $(this),
                    data = $this.data('AeroWindow'),
                    AeroWindow = $('<div />', {
                });

                // If the plugin hasn't been initialized yet
                if (!data) {
                    WindowID = $(this).attr('id');
                    if (($('body').data(WindowID)) == null) {
                        var $WindowAllwaysRegistered = false;
                        //Register this Window
                        $('body').data(WindowID, 1);
                    } else {
                        //Window exists
                        var $WindowAllwaysRegistered = true;
                    }
                    //If the window is registered, just show it and set focus ---------------     
                    //                    if ($WindowAllwaysRegistered == true) {
                    //                        Window = $(this).find(".AeroWindow");
                    //                        $(this).find(".AeroWindow").css('display', 'block');
                    //                        $(".AeroWindow").removeClass('active');
                    //                        if (Window.hasClass('AeroWindow')) Window.addClass('active');
                    //                        if (($('body').data('AeroWindowMaxZIndex')) == null) {
                    //                            $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
                    //                        }
                    //                        i = $('body').data('AeroWindowMaxZIndex');
                    //                        i++;
                    //                        Window.css('z-index', i);
                    //                        $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
                    //                        return;
                    //                    }
                    if (options) {
                        $.extend(settings, options);
                    }
                    var o = settings;

                    //Generate the new Window ---------------------------------------------     
                    var WindowContent = $(this).html();

                    //BTN --- 
                    if (o.WindowMinimize) {
                        if (o.WindowMaximize || o.WindowClosable) {
                            var WinMinBtn = '<a href="#" class="win-min-btn"></a><div class="win-btn-spacer"></div>';
                        } else {
                            var WinMinBtn = '<a href="#" class="win-min-btn"></a>';
                        }
                    } else {
                        var WinMinBtn = '';
                    }
                    //BTN ---
                    if (o.WindowMaximize) {
                        if (o.WindowClosable) {
                            var WinMaxBtn = '<div class="WinBtnSet winmax"><a href="#" class="win-max-btn"></a><div class="win-btn-spacer"></div></div>';
                            var WinRegBtn = '<div class="WinBtnSet winreg"><a href="#" class="win-reg-btn"></a><div class="win-btn-spacer"></div></div>';
                        } else {
                            var WinMaxBtn = '<div class="WinBtnSet winmax"><a href="#" class="win-max-btn"></a></div>';
                            var WinRegBtn = '<div class="WinBtnSet winreg"><a href="#" class="win-reg-btn"></a></div>';
                        }
                    } else {
                        var WinMaxBtn = '';
                        var WinRegBtn = '';
                    }
                    //BTN ---
                    if (o.WindowClosable) {
                        var WinCloseBtn = '<a href="#" class="win-close-btn"></a>';
                    } else {
                        var WinCloseBtn = '';
                    }

                    if (o.WindowMinimize || o.WindowMaximize || o.WindowClosable) {
                        var WinBtnLeftedge = '<div class="win-btn-leftedge"></div>';
                        var WinBtnRightedge = '<div class="win-btn-rightedge"></div>';
                    } else {
                        var WinBtnLeftedge = '';
                        var WinBtnRightedge = '';
                    }
                    $(this).html(
                          '<div class="AeroWindow">' +
                          '  <table cellpadding="0" cellspacing="0" border="0">' +
                          '    <tr>' +
                          '      <td class="table-tl"></td>' +
                          '      <td class="table-tm"></td>' +
                          '      <td class="table-tr"></td>' +
                          '    </tr>' +
                          '    <tr>' +
                          '      <td class="table-lm"></td>' +
                          '      <td class="table-mm" align="right">' +
                          '        <div class="title"><nobr>' + o.WindowTitle + '</nobr></div>' +
                          '        <div class="buttons">' +
                                     WinBtnLeftedge +
                                     WinMinBtn +
                                     WinMaxBtn +
                                     WinRegBtn +
                                     WinCloseBtn +
                                     WinBtnRightedge +
                          '        </div>' +
                          '        <div class="table-mm-container" align="left">' +
                          '          <div class="table-mm-content" style="width: ' + (o.WindowWidth !== 0 ? o.WindowWidth + 'px; height: ' : '100%; height: ') + (o.WindowHeight !== 0 ? o.WindowHeight + 'px;">' : '100%;">') +
                                       WindowContent +
                          '          </div>' +
                          '        </div>' +
                          '      </td>' +
                          '      <td class="table-rm"></td>' +
                          '    </tr>' +
                          '    <tr>' +
                          '      <td class="table-bl"></td>' +
                          '      <td class="table-bm"></td>' +
                          '      <td class="table-br"></td>' +
                          '    </tr>' +
                          '  </table>' +
                          '</div>'
                        );

                    //data object ---------------------------------------------------------
                    $(this).data('AeroWindow', {
                        target: $this,
                        AeroWindow: AeroWindow,
                        settings: settings,
                        Window: $(this).find(".AeroWindow"),
                        WindowContainer: $(this).find(".table-mm-container"),
                        WindowContent: $(this).find(".table-mm-content"),
                        BTNMin: $(this).find(".win-min-btn"),
                        BTNMax: $(this).find(".WinBtnSet.winmax"),
                        BTNReg: $(this).find(".WinBtnSet.winreg"),
                        BTNClose: $(this).find(".win-close-btn"),
                        Updater: _getUpdater($(this), o),
                        ParentSelector: _getParentSelector(o)
                    });


                    //Display hidden Containers -------------------------------------------
                    //$(this).css('display', 'block');

                    //Window Objects ------------------------------------------------------
                    var Window = $(this).data('AeroWindow').Window; //.find(".AeroWindow");
                    var WindowContainer = $(this).data('AeroWindow').WindowContainer; //.find(".table-mm-container");
                    var WindowContent = $(this).data('AeroWindow').WindowContent; //.find(".table-mm-content");
                    var BTNMin = $(this).data('AeroWindow').BTNMin; //.find(".win-min-btn");
                    var BTNMax = $(this).data('AeroWindow').BTNMax; //.find(".WinBtnSet.winmax");
                    var BTNReg = $(this).data('AeroWindow').BTNReg; //.find(".WinBtnSet.winreg");
                    var BTNClose = $(this).data('AeroWindow').BTNClose; //.find(".win-close-btn");
                    var Updater = $(this).data('AeroWindow').Updater;

                    if (Updater) {
                        //                        if (o.CloseAfterSubmit == true) {
                        //                            Updater.bind('postSuccess.AeroWindow', { context: $(this) }, function (event) {
                        //                                var data = event.data.context.data('AeroWindow');
                        //                                var o = data.settings;
                        //                                if (o.CloseAfterSubmit == true) {
                        //                                    event.data.context.AeroWindow('hide');
                        //                                }
                        //                            });
                        //                        }
                        Updater.bind('complete.AeroWindow', { context: $(this) }, function (event) {
                            var data = event.data.context.data('AeroWindow');
                            if (!data) {
                                return;
                            }

                            _setSize(event.data.context);
                            _center(event.data.context);
                            FocusWindow(data.Window);
                        });
                    }


                    //Initial Configuration -----------------------------------------------
                    BTNReg.css('display', 'none');
                    FocusWindow(Window);
                    _setOpacity($(this));

                    //Set Window Position
                    //debugger;
                    //                    Window.center({ parentSelector: o.WindowParentSelector });
                    //                    o.WindowPositionTop = Window.css('top');
                    //                    o.WindowPositionLeft = Window.css('left');

                    //                    if (o.WindowPositionTop == 'center') {
                    //                        $(this).center({ vertical: true, horizontal: false });
                    //                        //o.WindowPositionTop = ($(this).data('AeroWindow').ParentSelector.height() / 2) - o.WindowHeight / 2 - 37;
                    //                        o.WindowPositionTop = $(this).css('top');
                    //                    }
                    //                    if (o.WindowPositionLeft == 'center') {
                    //                        $(this).center({ vertical: false, horizontal: true });
                    //                        //o.WindowPositionLeft = ($(this).data('AeroWindow').ParentSelector.width() / 2) - o.WindowWidth / 2 - 17;
                    //                        o.WindowPositionTop = $(this).css('left');
                    //                    }

                    switch (o.WindowStatus) {
                        case 'regular':
                            $(this).AeroWindow('RegularWindow');
                            break;
                        case 'maximized':
                            $(this).AeroWindow('MaximizeWindow');
                            break;
                        case 'minimized':
                            $(this).AeroWindow('MinimizeWindow');
                            break;
                        case 'hidden':
                            $(this).AeroWindow('hide');
                            break;
                        default:
                            break;
                    }

                    //Attach user events to the Window ------------------------------------
                    if (o.WindowMaximize) {
                        $(this).bind("dblclick.AeroWindow", { context: $(this) }, function (event) {
                            switch (o.WindowStatus) {
                                case 'regular':
                                    event.data.context.AeroWindow('MaximizeWindow');
                                    break;
                                case 'maximized':
                                    event.data.context.AeroWindow('RegularWindow');
                                    break;
                                case 'minimized':
                                    event.data.context.AeroWindow('RegularWindow');
                                    break;
                                default:
                                    break;
                            }
                        });
                    } else {
                        $(this).bind("dblclick.AeroWindow", { context: $(this) }, function (event) {
                            switch (o.WindowStatus) {
                                case 'maximized':
                                    event.data.context.AeroWindow('RegularWindow');
                                    break;
                                case 'minimized':
                                    event.data.context.AeroWindow('RegularWindow');
                                    break;
                                default:
                                    break;
                            }
                        });
                    }
                    //User Interaction - Minimize Button
                    BTNMin.bind('click.AeroWindow', { context: $(this) }, function (event) {
                        FocusWindow(Window);
                        event.data.context.AeroWindow('MinimizeWindow');
                        return false;
                    });

                    //User Interaction - Maximize Button
                    BTNMax.bind('click.AeroWindow', { context: $(this) }, function (event) {
                        event.data.context.AeroWindow('MaximizeWindow');
                        return false;
                    });
                    //User Interaction - Regular Button
                    BTNReg.bind('click.AeroWindow', { context: $(this) }, function (event) {
                        FocusWindow(Window);
                        event.data.context.AeroWindow('RegularWindow');
                        return false;
                    });

                    //Close Button
                    BTNClose.bind('click.AeroWindow', { context: $(this) }, function (event) {
                        //Unregister this Window
                        event.data.context.AeroWindow('hide');
                        return false;
                    });

                    //Support Dragging ----------------------------------------------------
                    if (o.WindowDraggable) {
                        Window.draggable({
                            distance: 3,
                            cancel: ".table-mm-content",
                            start: function () {
                                FocusWindow(Window);
                                $(".AeroWindow").find('#iframeHelper').css({ 'display': 'block' });
                                $(".AeroWindow").removeClass('active');
                                $(this).addClass('active');
                                $('body').data('AeroWindowMaxZIndex', $(this).css('z-index'));
                            },
                            drag: function () {
                                WindowTop = -1 * $(this).offset().top;
                                WindowLeft = -1 * $(this).offset().left;
                                $(this).css({ backgroundPosition: WindowLeft + 'px ' + WindowTop + 'px' });
                            },
                            stop: function () {
                                //alert(Window.css('top'));
                                o.WindowPositionTop = Window.css('top');
                                o.WindowPositionLeft = Window.css('left');
                                $(".AeroWindow").find('#iframeHelper').css({ 'display': 'none' });
                            }
                        });
                    }

                    //Support Focus on Window by Click ------------------------------------
                    Window.click(function () {
                        FocusWindow(Window);
                    });

                    //Support Window Resizing ---------------------------------------------
                    if (o.WindowResizable) {
                        Window.resizable({
                            minHeight: o.WindowMinHeight + 72,
                            minWidth: o.WindowMinWidth,
                            alsoResize: WindowContent,
                            start: function () {
                                WindowContainer.css('visibility', 'visible');
                                $(".AeroWindow").find('#iframeHelper').css({ 'display': 'block' });
                                $(".AeroWindow").removeClass('active');
                                Window.addClass('active');
                                if (($('body').data('AeroWindowMaxZIndex')) == null) {
                                    $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
                                }
                                i = $('body').data('AeroWindowMaxZIndex');
                                i++;
                                Window.css('z-index', i);
                                $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
                            },
                            stop: function () {
                                o.WindowWidth = WindowContent.width();
                                o.WindowHeight = WindowContent.height();
                                $(".AeroWindow").find('#iframeHelper').css({ 'display': 'none' });
                            }
                        });
                    }
                    $(window).bind('unload', { context: $(this) }, function (event) {
                        event.data.context.AeroWindow('destroy');
                    });
                    if (o.AutoOpen) {
                        $(this).AeroWindow('show');
                    }
                    else if (o.DeferLoad && $(this).css('display') == 'block') {
                        //_setSize($(this), true);
                        //_center($(this));
                        var updater = data.Updater;
                        if (updater) {
                            updater.jupdater('refresh');
                        }
                    }
                    else {
                        //_setSize($(this));
                        //_center($(this));
                    }
                };
            });
        },

        destroy: function () {
            return this.each(function () {
                var $this = $(this), data = $this.data('AeroWindow');

                $(window).unbind('.AeroWindow');
                if (data) {
                    data.AeroWindow.remove();
                    $this.removeData('AeroWindow');
                }
            })
        },

        //Window Functions ----------------------------------------------------
        MaximizeWindow: function () {
            var $this = $(this), data = $this.data('AeroWindow');
            var o = data.settings;

            data.WindowContainer.css('visibility', 'visible');
            data.BTNMax.css('display', 'none');
            data.BTNReg.css('display', 'block');
            data.WindowContent.animate({
                width: data.ParentSelector.width() - 22,
                height: data.ParentSelector.height() - 67
            }, {
                queue: false,
                duration: o.WindowAnimationSpeed,
                easing: o.WindowAnimation
            });
            //Set new Window Position
            data.Window.animate({
                width: data.ParentSelector.width(),
                height: data.ParentSelector.height(),
                top: 0,
                left: 0
            }, {
                duration: o.WindowAnimationSpeed,
                easing: o.WindowAnimation
            });
            o.WindowStatus = 'maximized';
            FocusWindow(data.Window);
            return (false);
        },

        MinimizeWindow: function () {
            var $this = $(this), data = $this.data('AeroWindow');
            var o = data.settings;

            data.BTNReg.css('display', 'block');
            data.BTNMax.css('display', 'none');
            data.WindowContainer.css('visibility', 'hidden');
            data.WindowContent.animate({
                width: o.WindowMinWidth,
                height: o.WindowMinHeight
            }, {
                queue: true,
                duration: o.WindowAnimationSpeed,
                easing: o.WindowAnimation
            });
            //Set new Window Position
            data.Window.animate({
                width: o.WindowMinWidth + 22,
                height: o.WindowMinHeight + 62,
                top: data.ParentSelector.height() - 67,
                left: 0
            }, {
                duration: o.WindowAnimationSpeed,
                easing: o.WindowAnimation
            });
            o.WindowStatus = 'minimized';
            FocusWindow(data.Window);
            return (false);
        },

        RegularWindow: function () {
            var $this = $(this), data = $this.data('AeroWindow');
            var o = data.settings;

            data.BTNMax.css('display', 'block');
            data.BTNReg.css('display', 'none');
            data.WindowContainer.css('visibility', 'visible');
            //_setSize($(this));
            //            if (o.WindowWidth === 0) {
            //                data.WindowContent.css('width', o.WindowMinWidth + 'px');
            //                o.WindowWidth = data.Window.width();
            //            }
            //            if (o.WindowHeight === 0) {
            //                data.WindowContent.css('height', o.WindowMinHeight + 'px');
            //                o.WindowHeight = data.Window.height();
            //            }
            //data.Window.width(o.WindowWidth);
            //data.Window.height(o.WindowHeight);
            //            data.Window.center({ parentSelector: o.WindowParentSelector });
            //            o.WindowPositionTop = data.Window.css('top');
            //            o.WindowPositionLeft = data.Window.css('left');

            //            data.WindowContent.animate({
            //                width: o.WindowWidth,
            //                height: o.WindowHeight
            //            }, {
            //                queue: false,
            //                duration: o.WindowAnimationSpeed,
            //                easing: o.WindowAnimation
            //            });
            //            data.Window.animate({
            //                width: o.WindowWidth + 22,
            //                height: o.WindowHeight + 62
            //            }, {
            //                queue: false,
            //                duration: o.WindowAnimationSpeed,
            //                easing: o.WindowAnimation
            //            });
            //            //Set new Window Position
            //            //Error handling, if the left position is negative.
            //            if ((typeof (o.WindowPositionLeft) == 'string') && (o.WindowPositionLeft.substring(0, 1) == '-')) o.WindowPositionLeft = 0;
            //            data.Window.animate({
            //                top: o.WindowPositionTop,
            //                left: o.WindowPositionLeft
            //            }, {
            //                duration: o.WindowAnimationSpeed,
            //                easing: o.WindowAnimation
            //            });
            o.WindowStatus = 'regular';
            FocusWindow(data.Window);
            return (false);
        },

        hide: function () {
            return this.each(function () {
                var $this = $(this), data = $this.data('AeroWindow');
                //debugger;
                if (data) {
                    $(this).css('visibility', 'hidden')
                    $(this).hide();
                    if (data.settings.WindowStatus == 'hidden') {
                        data.settings.WindowPrevStatus = 'regular';
                    }
                    else {
                        data.settings.WindowPrevStatus = data.settings.WindowStatus;
                    }

                    if (data.settings.DeferLoad) {
                        var updater = data.Updater;
                        if (updater) {
                            updater.html('');
                        }
                    }
                }
            });
        },

        show: function () {
            return this.each(function () {
                var $this = $(this), data = $this.data('AeroWindow');
                //debugger;
                var wasHidden = $(this).css('display') == 'none';
                $(this).css('visibility', 'visible');
                $(this).show();
                if (data) {
                    switch (data.settings.WindowPrevStatus) {
                        case 'regular':
                            $(this).AeroWindow('RegularWindow');
                            break;
                        case 'maximized':
                            $(this).AeroWindow('MaximizeWindow');
                            break;
                        case 'minimized':
                            $(this).AeroWindow('MinimizeWindow');
                            break;
                        case 'hidden':
                            $(this).AeroWindow('hide');
                            break;
                        default:
                            break;
                    }
                    //debugger;
                    FocusWindow(data.Window);
                    if (data.settings.DeferLoad === true) {
                        _setSize($(this), true);
                        _center($(this));
                        var updater = data.Updater;
                        if (updater && wasHidden) {
                            updater.html('');
                            updater.jupdater('refresh');
                        }
                    }
                    else {
                        _setSize($(this));
                        _center($(this));
                    }
                }
            });
        },

        title: function (title) {
            return this.each(function () {
                var $this = $(this), data = $this.data('AeroWindow');
                if (data) {
                    data.settings.WindowTitle = title;
                    $(this).find(".title").html('<nobr>' + data.settings.WindowTitle + '</nobr>');
                }
            });
        },

        setParam: function (param) {
            return this.each(function () {
                var $this = $(this), data = $this.data('AeroWindow');
                var updater = data.Updater;
                if (updater) {
                    updater.jupdater('setParam', param);
                }
            })
        }
    };

    $.fn.AeroWindow = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.AeroWindow');
        }
    };

    function FocusWindow(Window) {
        $(".AeroWindow").removeClass('active');
        if (Window.hasClass('AeroWindow')) Window.addClass('active');
        if (($('body').data('AeroWindowMaxZIndex')) == null) {
            $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
        }
        i = $('body').data('AeroWindowMaxZIndex');
        i++;
        Window.css('z-index', i);
        $('body').data('AeroWindowMaxZIndex', Window.css('z-index'));
    };

    function _getUpdater($context, $settings) {
        var updaterId = $settings.UpdaterID;
        if (updaterId && updaterId !== '') {
            var updater = $('#' + updaterId);
            if (updater && updater.length > 0) {
                return updater;
            }
        }
        return null;
    };

    function _center($context) {
        var $this = $context, data = $this.data('AeroWindow');
        if (!data) {
            return;
        }
        var o = data.settings;
        o.WindowPositionTop = ($(window).height() / 2) - o.WindowHeight / 2 - 37;
        o.WindowPositionLeft = ($(window).width() / 2) - o.WindowWidth / 2 - 17;
        $context.offset({ top: o.WindowPositionTop, left: o.WindowPositionLeft });
    };

    function _setSize($context, isRefresh) {
        var $this = $context, data = $this.data('AeroWindow');
        if (!data) {
            return;
        }
        var o = data.settings;

        //        if (o.AutoSize && data.Updater.children().length == 0) {
        //            o.WindowWidth = 0;
        //            o.WindowHeight = 0;
        //        }

        if (o.WindowWidth === 0) {
            if (o.AutoSize) {
                data.WindowContent.css('width', '100%');
                //o.WindowWidth = data.Window.outerWidth();
            }
            else data.WindowContent.css('width', o.WindowMinWidth + 'px');

            o.WindowWidth = data.Window.outerWidth();
        }

        if (o.WindowHeight === 0) {
            if (o.AutoSize) {
                data.WindowContent.css('height', '100%');
                o.WindowHeight = data.Window.outerHeight();
            }
            else data.WindowContent.css('height', o.WindowMinHeight + 'px');

            o.WindowHeight = data.Window.outerHeight();
        }
    };

    function _setOpacity($context) {
        return;
        var $this = $context, data = $this.data('AeroWindow');
        if (!data) {
            return;
        }
        var o = data.settings;
        if (o.Opacity > 1 || o.Opacity < 0) {
            return;
        }
        if (!data.Window || !data.WindowContainer) {
            return;
        }
        data.Window.find('.table-tl, .table-tm, .table-tr, .table-lm, .table-mm, .table-rm, .table-bl, .table-bm, .table-br').css('opacity', o.Opacity);
        data.WindowContainer.css('opacity', '');
    };

    function _getParentSelector($settings) {
        if ($settings.WindowParentSelector == '') {
            return $(window);
        }
        else {
            return $($settings.WindowParentSelector);
        }
    }
})(jQuery);